package game;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.*;

public class SnakeMidlet extends MIDlet implements CommandListener {

    Display display;
    static final Command ComandoSair = new Command("Sair", Command.EXIT, 0);
    SnakeCanvas canvas = new SnakeCanvas();

    public void startApp() {

        display = Display.getDisplay(this);
        canvas.addCommand(ComandoSair);
        canvas.setCommandListener(this);
        display.setCurrent(canvas);
        canvas.start();

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {

        notifyDestroyed();
    }

    public void commandAction(Command c, Displayable d) {
        if (c.getCommandType() == Command.EXIT && c == ComandoSair) {
            canvas.stop();
            destroyApp(true);
        }
             
    }
}
